-
-
Notifications
You must be signed in to change notification settings - Fork 27k
feat(webpack): svg loader rules have been updated #12646
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
feat(webpack): svg loader rules have been updated #12646
Conversation
Hi @lucabattistini! Thank you for your pull request and welcome to our community. Action RequiredIn order to merge any pull request (code, docs, etc.), we require contributors to sign our Contributor License Agreement, and we don't seem to have one on file for you. ProcessIn order for us to review and merge your suggested changes, please sign at https://code.facebook.com/cla. If you are contributing on behalf of someone else (eg your employer), the individual CLA may not be sufficient and your employer may need to sign the corporate CLA. Once the CLA is signed, our tooling will perform checks and validations. Afterwards, the pull request will be tagged with If you have received this in error or have any questions, please contact us at [email protected]. Thanks! |
Thank you for signing our Contributor License Agreement. We can now accept your code for this (and any) Meta Open Source project. Thanks! |
Hi @mrmckeb, following the svgr/webpack documentation (https://react-svgr.com/docs/webpack/) the 'babel-plugin-named-asset-import' seems to be unnecessary, what do you think? It can be removed? |
@lucabattistini why not only add the option {
test: /\.svg$/,
use: [
{
loader: require.resolve('@svgr/webpack'),
options: {
prettier: false,
svgo: false,
svgoConfig: {
plugins: [{ removeViewBox: false }],
},
titleProp: true,
ref: true,
},
},
{
loader: require.resolve('file-loader'),
options: {
name: 'static/media/[name].[hash].[ext]',
emitFile: false,
},
},
], |
@artola because according to the webpack v5 doc, file-loader is deprecated in favor of asset modules |
excuses for pinging, any progress here? |
When SVG files are imported (both as ReactComponent or url) and thus inlined in the bundle are also included, in a mistaken way, in the
build/static/media
and consequence into theasset-manifest.json
.This behaviour is critical when using Service Worker because at the start of the application the browser will send all the pre-cache request for all these SVG files that don't need at all.
This PR resolves #9167
This is a working example created by ejecting the config of a cra template:
my-app.zip